package com.hd.trans.share;

import android.text.TextUtils;

// 网络请求错误码
public class NetCode {
    private NetCode() {
    }

    public static final int RESULT_SUCCESS = 10000;

    public static final int ERROR_RECOGNIZE_CONTINUE_INT = 20000;
    // 已分享
    public static final int ERROR_ALREADY_SHARE = 52015;
    // 继续轮询
    public static final int CONTINUE_POLLING = 50000;
    // -22001	failure	token过期
    public static final int ERROR_USER_TOKEN_EXPIRED = -22001;
    // -22002	failure	token无效
    public static final int ERROR_USER_TOKEN_INVALID = -22002;
    //taskstate查询转换状态，处理失败
    public static final int ERROR_TASK_STATE_DEAL = 52500;
    //taskstate查询转换状态，处理失败statusdetail为-199
    public static final int ERROR_TASK_STATE_STATUS_DETAIL = -199;
    // 本地定义
    // 其他错误
    public static final int RESULT_UNKNOWN = -1;
    // 取消
    public static final int RESULT_CANCEL = 9000000;
    // 连接服务器出错
    public static final int I_ERROR_NET_ERROR = 9000002;
    // 解析code出错
    public static final int I_ERROR_PARSE_ERROR = 9000003;
    // 请检查网络连接
    public static final int STATE_ERROR_NO_NET = 9004;
    // 网络连接超时
    public static final int STATE_ERROR_TIME_OUT = 9005;
    // 任务取消异常
    public static final int STATE_ERROR_CANCEL = 9006;
    // 内存不足
    public static final int STATE_ERROR_OOM = 9007;
    // txt文件解析失败
    public static final int LC_ERROR_TXT_PARSE_FAIL = 990000;
    // 不支持该格式
    public static final int LC_ERROR_NOT_SUPPORT = 990001;
    // 仅支持10M以内的文档
    public static final int LC_ERROR_ONLY_SUPPORT_10M = 990002;
    // 找不到系统管理器
    public static final int LC_ERROR_NOT_FOUND_FILE_MANAGE = 990003;
    // 本地uri解析失败
    public static final int LC_ERROR_URI_PARSE_FAIL = 990004;
    // 请求QQ授权失败
    public static final int LC_QQ_AUTH_FAIL = 10000001;


    //本地手机错误
    public static final String ERROR_CODE_SYSTEM_ERROR = I_ERROR_NET_ERROR + "";
    //本地大小时长校验不通过
    public static final String ERROR_LOCAL_SIZE_LIMIT = "-1000";
    //新加任务 网络连接错误
    public static final String ERROR_AT_NETWORK_ERROR = "-1100";
    //上传文件 网络连接错误
    public static final String ERROR_UPLOAD_NETWORK_ERROR = "-1200";
    //识别结果 识别中
    public static final String ERROR_RECOGNIZE_CONTINUE = "20000";


    //识别结果 文件太大
    public static final String ERROR_RECOGNIZE_SIZE_LIMIT = "10015";
    //识别结果 超时
    public static final String ERROR_RECOGNIZE_TIME_OUT = "-201700";
    //识别结果 服务器挂掉之类，服务器返回
    public static final String ERROR_RECOGNIZE_FAIL_2 = "18000";

    //服务器错误
    public static final String ERROR_CODE_SERVER_ERROR = "-201704";
    //签名错误
    public static final String ERROR_CODE_SIGNATURE_ERROR = "11110";
    //VIP过期
    public static final String ERROR_CODE_VIP_ERROR = "10050";

    //结果反馈正确
    public static final String CODE_SUCCESS = "10000";

    // code=28001 风险验证没有通过，需要再通过 api/v4/imgverify，
    public static final int I_ERROR_REQ_SMS_SAFE_LIMIT_1 = 28001;
    public static final int I_ERROR_REQ_SMS_SAFE_LIMIT_2 = 28002;


    // 云存储--回执说明
    public static final int ERROR_CLOUD_USER_TOKEN_ERROR = 20017;
    public static final int ERROR_CLOUD_USER_TOKEN_INVALID = 20018;

    // 继续上传
    public static final int RESULT_BLOCK_UPLOAD_CONTINUE = 11000;

    // 分块上传失败
    public static final int ERROR_BLOCK_UPLOAD_FAIL = -1200;
    // 下载失败
    public static final int ERROR_DOWNLOAD_FAIL = -5200001;
    // QQ未安装
    public static final int ERROR_QQ_NOT_INSTALL = -5200002;
    // 用户基础信息为空
    public static final int ERROR_USER_INFO_IS_NULL = -25001;


    // 11108 缺少或错误的 timestamp
    public static final int ERROR_WRONG_TIMESTAMP = 11108;
    // 11120 缺少或错误的 data sign
    public static final int ERROR_DATASIGN_WRONG_TIMESTAMP = 11120;

    // 安全解析code
    public static int getCode(String code) {
        if (TextUtils.isEmpty(code)) {
            return NetCode.I_ERROR_PARSE_ERROR;
        }
        try {
            return Integer.parseInt(code);
        } catch (Exception e) {
            return NetCode.I_ERROR_PARSE_ERROR;
        }
    }
}
